package day03;

import java.security.spec.RSAOtherPrimeInfo;

//运算符的演示
public class OperDemo {
    public static void main(String[] args) {
        /*
        int a = 5,b=3;
//        a++;//单独使用相当于a=a+1
//        b++;//单独使用相当于b=b+1
        int c = a++;//将a++的值5赋值给c,同时a自增1
                    //简便记法:a++的值为5,所以c就为5
        int d = ++b;//将++b的值赋值给d,同时b自增1
                    //简便记法:b++的值为3,所以b就为4
        System.out.println(a);//6
        System.out.println(b);//4
        System.out.println(c);//5
        System.out.println(d);//4
         */
        //2关系运算度
        /*int a = 4,b=8,c=4;
        boolean b1 = a>b;
        System.out.println(b1);//false
        System.out.println(a<b);//true
        System.out.println(a==c);//true
        System.out.println(a!=c);//false
        System.out.println(b-a+4==b);//true
        System.out.println(a>=c);//true
        System.out.println(a%2==0);//true
        System.out.println(a++>=c);//true------a自增1,变为5
        System.out.println(a++==c);//false------a自增1变为6
         */
        //3.逻辑运算符
        /*
        int a=5,b=10,c=5;
        boolean b1 = b>=a && b<c;//true&&false=false
        System.out.println(b1);
        System.out.println(b<=a&&a!=c);//false&&false=false
        System.out.println(a<c&&b>=5);//false&&true=false
        System.out.println(b>a&&a==c);//true&&true=true
        int age = 22;
        System.out.println(age>=18 && age<=50);//年龄在18到50之间
        int score = 84;
        System.out.println(score>=0 && score<=100);//成绩在0-100之间
         */
        /*
        int a=5,b=10,c=19;
        System.out.println(a<=b||c<10);//true||false=true
        System.out.println(a>c||c>=a);//false||true=true
        System.out.println(a<b||c>a);//true||true=true
        System.out.println(a>b||c==b);//false||false
        int score = 80;
        System.out.println(score<0 || score>100);//成绩不合法验证
        boolean b2 = !(a>b);
        System.out.println(b2);     //!false=true
        System.out.println(!(a<c)); //!true=false

         */
        /*int a=5,b=10,c=5;
        boolean b2 = a<b || c++>2;
        System.out.println(b2);//true
        System.out.println(c);//5,发生短路了

         */
        /*
        int a=5,b=10,c=5;
        boolean b2 = a>b && c++>2;
        System.out.println(b2);//false
        System.out.println(c);//5,发生短路了
         */
        /*
        //小面试题v
        short s = 5;
        //s = s+10;编译错误,需强转,改为s=(short)(s+10);
        s += 10;//相当于s=(short)(s+10);
        int a = 5;
        a += 10;//相当于a=(int)(a+10);
        System.out.println(a);//15
        a *= 2;//相当于a=(int)(a*2);
        System.out.println(a);//30
        a/=3;//相当于a=(int)(a/3);
        System.out.println(a);//10
         */
        /*
        int age = 23;
        System.out.println("age=");//age=
        System.out.println(age);//23
        System.out.println("age="+age);//age=39
        System.out.println("我今年"+age+"岁了");//我今年39岁了
        String name = "ssj";
        System.out.println("大家好,我叫"+name);//大家好,我叫Mkj
        System.out.println("大家好,我叫"+name+",今年"+age+"岁了");
         */
        //字符串运算连接符:
        //1)若两边为数字,则做加法运算
        //2)若两边出现了字符串,则做字符串拼接
        //3)任何类型数据和字符串相连,结果都是字符串类型
//        System.out.println(12+14+""+23);//2623------String
//        System.out.println(""+12+34+2);//12342------String
//        System.out.println(23+23+1+2+"");//49------String
        /*
        6.条件/三目运算符:
        1)语法:
            boolean?数1:数2
        2)执行过程:
            整个表达式是有值的,他的值要么是?号后的数1,要么是;号后的数2
            计算boolean的值:
                若为true,则整个表达式的结果为?号后的数1
                若为false,则整个表达式的结果为:后的数2
         */
        int num = 12;
        int flag = num>0?1:-1;
        System.out.println(flag);
        //找两个数中的最大值
        int a=5,b=3;
        int max = a>b?a:b;
        System.out.println(max);
    }
}